package mest.controller.Modeling;

import com.alibaba.fastjson.JSON;
import mest.entity.provider_type;
import mest.entity.save_type;
import mest.service.Modeling.IsaveTypeService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description
 * @auther Machenike
 * @create 2019-11-15 23:27
 */
@RestController
@CrossOrigin
@RequestMapping(value = "/saveType")
public class saveType {
    @Resource
    private IsaveTypeService ipfs;

    @RequestMapping(value="/insert")
    public String insert(save_type pt ){
        int i = ipfs.insertsaveType(pt);
        if (i >= 1)
            return JSON.toJSONString("添加成功");
        else
            return JSON.toJSONString("添加失败");
    }
    @RequestMapping(value = "/baseSelect", produces = {"application/json;charset=utf-8", "text/plain;charset=utf-8"})
    public String baseSelect(int index,int pageSize) {

        List<save_type> saveTypePage = ipfs.findSaveTypePage(index, pageSize);
        int i = ipfs.selectCount();
        Map map  = new HashMap();
        map.put("code",0);
        map.put("msg","");
        map.put("count",i);
        map.put("data",saveTypePage);
        return JSON.toJSONString(map);
    }
}
